//      startup.c
//      
//      Copyright 2011 DJ Shaji <djshaji@gmail.com>
//      
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 2 of the License, or
//      (at your option) any later version.
//      
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//      
//      You should have received a copy of the GNU General Public License
//      along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.


#include "startup.h"
#include "util.h"

void startup ( gint argc, gchar ** argv )
{
	gtk_init ( & argc, & argv ) ;
	g_set_application_name ( "Shell" ) ;
	
	g_set_prgname ( "Shell" ) ;
	
	g_log_set_handler ( null, G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE |
						G_LOG_LEVEL_INFO | G_LOG_LEVEL_WARNING |
						G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR,
						shell_log_handler, null ) ;
	
	/*
	g_log_set_handler ( "Gtk", G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE |
						G_LOG_LEVEL_INFO | G_LOG_LEVEL_WARNING |
						G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR,
						shell_log_handler, null ) ;
	g_log_set_handler ( "Glib", G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE |
						G_LOG_LEVEL_INFO | G_LOG_LEVEL_WARNING |
						G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR,
						shell_log_handler, null ) ;
	*/
	
	
	gchar * fav = g_build_filename ( g_get_home_dir (), ".system/favorites.db", null ) ;
	if ( ! g_file_test ( fav, G_FILE_TEST_EXISTS ))
	{
		gchar * message = { "# April explorer favorites\n\n" } ;
		g_file_set_contents ( fav, message, strlen ( message ), null ) ;
	}
	
	g_free ( fav ) ;
	
	desktop_init () ;
	gtk_main () ;
}
